import {createRouter, createWebHashHistory} from 'vue-router';
import {getMenuList, getCaptchaImg} from '../axios/index';
import axios from 'axios';
import { nextTick } from 'vue';
const router =  createRouter({
    history: createWebHashHistory(),
    routes: [
        {
            path: '/',
            name:'index',
            component: ()=> import('views/Index/index.vue'),
            children:[
                {
                    path: '/sys/main',
                    name:'main',
                    component: ()=> import('views/MainContainer/index.vue')
                },
                {
                    path: '/sys/menu',
                    name:'menu',
                    component: ()=> import('views/MainContainer/sys/Menu.vue')
                },
                {
                    path: '/sys/user',
                    name:'user',
                    component: ()=> import('views/MainContainer/sys/User.vue')
                },
                {
                    path: '/sys/role',
                    name:'role',
                    component: ()=> import('views/MainContainer/sys/Role.vue')
                },
                {
                    path: '/sys/book',
                    name:'book',
                    component: ()=> import('views/MainContainer/sys/Book.vue')
                },
                {
                    path: '/userCenter',
                    name:'userCenter',
                    component: ()=> import('views/MainContainer/UserCenter/index.vue')
                },
            ]

        },
        {
            path: '/login',
            name:'login',
            component: ()=> import('views/Login/login/index.vue')
        },
        {
            path: '/register',
            name:'register',
            component: ()=> import('views/Login/register/index.vue')
        },
        
    ]

})

router.beforeEach(  (to, from, next)=>{
    // axios.get('/mock/sys/menu/nav')
    // console.log(data);
    next()
} )


export default router;